﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DARE;
using Microsoft.Xna.Framework;

namespace DARE
{
    /// <summary>
    /// [Deprecated][Not commented]
    /// A dialog box is a simple interface with one text area and one list of answers.
    /// </summary>
    [AttrTypeDependentSerializable(typeof(CDialogBoxData))]
    public class CDialogBox: CWidget
    {
        #region fields

        private CStaticText m_question;
        private CListBox m_answers;

        #endregion

        #region properties

        public CListBox Answers { get { return m_answers; } }

        #endregion

        #region ctor

        public CDialogBox(CHUDSystem hud, CWidget parent, string name)
            : base(hud, null, name)
        {
            IsInputConsumer = true;
            IsClickable = true;
            m_isVisible = true;

            m_question = new CStaticText(hud, this, name + "_Question");
            m_question.Size = new Vector2(1, 0.3f);
            m_question.Position = new Vector2(0, 0);

            m_answers = new CListBox(hud, this, name + "_Answers");
            m_answers.Size = new Vector2(1, 0.7f);
            m_answers.Position = new Vector2(0, 0.3f);
        }

        #endregion

        #region getElements

        #endregion

        #region events

        #endregion

        #region methods

        public void AttachToHUD(CHUDSystem hud)
        {
            HUD = hud;
            m_question.HUD = hud;
            m_answers.HUD = hud;
        }

        public void SetQuestion(string question)
        {
            m_question.Text = question;
        }

        public void ClearAnswers()
        {
            m_answers.CWidgetList.Clear();
        }
        
        public void AddAnswer(string name, string answer, eventMethod onClick, eventMethod onRelease)
        {
            CStaticText text = new CStaticText(HUD, null, name);
            text.Text = answer;
            text.OnRelease += onRelease;
            text.OnClick += onClick;
            //text.Size = new Vector2(1, 0.3f);
            m_answers.Add(text);
        }

        #endregion

    }
}
